package cn.shengchao.util;

import cn.shengchao.qywx.acl.IRuleDomainService;
import cn.shengchao.rule.engine.IRule;
import cn.shengchao.rule.engine.RuleEngine;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @program: examstarapi
 * @description: 规则引擎构造器
 * @author: Xiong weiqiang
 * @create: 2025-04-11 21:04
 */
@Component
public class RuleEngineBuilder {
    @Autowired
    IRuleDomainService ruleDomainService;
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    @PostConstruct
    public void init() {
            System.out.println("初始化规则引擎..................开始========");
            List<IRule> list = ruleDomainService.fetchDatabaseRules();
            System.out.println("初始化规则引擎......找到规则" + list.size() + "条========");
            RuleEngine.cleanAndLoadRules(list);
            System.out.println("初始化规则引擎..................结束========");
    }
}